// Calendar Onchange Handler
// y(ear),m(onth),d(ay)が変更された直後
// d = 0 means the calendar is about to switch to the month of (y,m); 
// d > 0 means a specific date [y,m,d] is about to be selected.
// e is a reference to the triggering event object
// Return a true value will cancel the change action.
////////////////////////////////////////////////////////////////////
// function fOnChange(y,m,d,e) {}

// Calendar AfterSelected Handler
//日付が選択された直後
function fAfterSelected(y,m,d,e) {
  var now = [y +"/"+ m +"/"+ d];
  var f = Getdata();
  var j = Getmid();
  var t = Getlid();
  var v = Getviewtype();
  window.parent.location.href = '../detail.cgi?status=hour&mid=' + j + '&SID=' + f + '&date=' + now + '&lids=' + t + '&types=' + v;
} 

//popupCal用
//function fAfterSelected_cal(y,m,d,e) {
//  alert([y +"年"+ m +"月"+ d+"日"]);
//}

///////////// Calendar Cell OnDrag Handler ///////////////////////
// It triggered when you try to drag a calendar cell. (y,m,d) is the cell date. 
// aStat = 0 means a mousedown is detected (dragstart)
// aStat = 1 means a mouseover between dragstart and dragend is detected (dragover)
// aStat = 2 means a mouseup is detected (dragend)
// e is a reference to the triggering event object
// Return true (when aStat=0) to skip the set-date process, as well as any related event handlers (e.g. fAfterSelect).
////////////////////////////////////////////////////////////////////
// function fOnDrag(y,m,d,aStat,e) {}

// Calendar OnResize Handler
// カレンダが描画された直後
//function fOnResize() {
//	alert("描画終了");
//}

// Calendar fOnWeekClick Handler
// 週が選択された直後
// function fOnWeekClick(year, weekNo) {}
function fOnWeekClick(year, weekNo) {
  var f = Getdata();
  var week = year +"/"+ weekNo;
  var j = Getmid();
  var t = Getlid();
  var v = Getviewtype();
 window.parent.location.href = '../detail.cgi?status=dayw&mid=' + j + '&SID=' + f + '&date=' + week + '&lids=' + t + '&types=' + v;
}

// Calendar fIsSelected Callback
// It's triggered for every date passed in as y(ear) m(onth) d(ay). And if 
// the return value is true, that date will be rendered using the giMarkSelected,
// gcFGSelected, gcBGSelected and guSelectedBGImg theme options.
////////////////////////////////////////////////////////////////////
// function fIsSelected(y,m,d) {
//		return gdSelect[2]==d&&gdSelect[1]==m&&gdSelect[0]==y;
// }


function popup(url,framename) {	
	var w=parent.open(url,framename,"top=200,left=200,width=400,height=200,scrollbars=1,resizable=1");
	if (w&&url.split(":")[0]=="mailto") w.close();
	else if (w&&!framename) w.focus();
}

// return the d(ate) of the q-th n-day of a specific m(onth) in a specific y(ear)
function getDateByDOW(y,m,q,n) { 
// q: 1 - 5 ( 5 denotes the last n-day )
// n: 0 - Sunday, 1 - Monday ... 6 - Saturday
	var dom=new Date(y,m-1,1).getDay();
	var d=7*q-6+n-dom;
	if (dom>n) d+=7;
	if (d>fGetDays(y)[m]) d-=7;
	return d;	// ranged from 1 to 31
}

//曜日をクリック後
function fOnDayClick(y,m,day) {

	switch(day){

	    case 1:
	        day="1";
	        break;
	    case 2:
	        day="2";
	        break;
	    case 3:
	        day="3";
	        break;
	    case 4:
	        day="4";
	        break;
	    case 5:
	        day="5";
	        break;
	    case 6:
	        day="6";
	        break;
	    case 7:
	        day="0";
	        break;
	} 
	var weekday = [y +"/"+ m +"/"+ day];
	var f = Getdata();
    var j = Getmid();
	var t = Getlid();
	var v = Getviewtype();
	window.parent.location.href = '../detail.cgi?status=youbi&mid=' + j + '&SID=' + f + '&date=' + weekday + '&lids=' + t + '&types=' + v;
}

